#ifndef __IST8310_H
#define __IST8310_H
#include "stm32f4xx.h"

/*************** DEVICE I2C SLAVE ADDRESS SELECT *************
	CAD1		CAD0		Address(7-bit)    Address(8-bit)
	VSS			VSS			0X0C							0X18
	VSS			VDD			0X0D							0X1A
	VDD			VSS			0X0E							0X1C
	VDD			VDD			0X0F							0X1E
	
	here, CAD1 = CAD0 = VSS, so address = 0x0c(7bit) or 0x18(8bit)
**************************************************************/

#define IST8310_ADDRESS 	0x18

#define IST8310_WHO_AM_I  0X00
#define IST8310_STA_REG1	 	  0X02
#define IST8310_OUT_X_L				0X03
#define IST8310_OUT_X_H				0X04
#define IST8310_OUT_Y_L       0X05
#define IST8310_OUT_Y_H				0X06
#define IST8310_OUT_Z_L       0X07
#define IST8310_OUT_Z_H				0X08
#define IST8310_STA_REG2			0X09
#define IST8310_CONF_REG1			0X0A
#define IST8310_CONF_REG2			0X0B
#define IST8310_SELF_TEST			0X0C
#define IST8310_OUT_T_L				0X1C
#define IST8310_OUT_T_H				0X1D
#define IST8310_AVGCNTL				0X41
#define IST8310_PDCNTL				0x42


#define WRITE_CMD     0x01
#define READ_CMD			0X00


typedef struct
{
	s16 x_axis;
	s16 y_axis;
	s16 z_axis;
	s16 temp;
} MAGREG_TypeDef;

void IST8310_Init(void);
u8 Read_MAG3axis(MAGREG_TypeDef *sensor);
void ReverseMagPor(bool dir);

#endif
/***************************************END OF FILE IST8310_H***********************************************/